﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Collections.ObjectModel;

namespace SLControlLibrary.Resources.Controls.Calendar.Common
{
    public class Utility
    {
        #region AddRanage
        public static void AddRange<T>(List<T> _InList, ref List<T> _OutList, bool _ClearList)
        {
            if (_ClearList && (_OutList != null) && _OutList.Count > 0)
                _OutList.Clear();

            foreach (T _Item in _InList)
                _OutList.Add(_Item);
        }

        public static void AddRange<T>(List<T> _InList, ref UIElementCollection _OutList, bool _ClearList)
        {
            if (_ClearList && (_OutList != null) && _OutList.Count > 0)
                _OutList.Clear();

            foreach (T _Item in _InList)
                _OutList.Add((UIElement)((object)_Item));
        }

        public static UIElementCollection AddRange<T>(List<T> _InList, UIElementCollection _OutList, bool _ClearList)
        {
            if (_ClearList && (_OutList != null) && _OutList.Count > 0)
                _OutList.Clear();

            foreach (T _Item in _InList)
                _OutList.Add((UIElement)((object)_Item));

            return _OutList;
        }
        #endregion

        #region AddDays
        public static DateTime? AddDays(DateTime time, int days)
        {
            System.Globalization.Calendar cal = new GregorianCalendar();

            try
            {
                return cal.AddDays(time, days);
            }
            catch (System.ArgumentException)
            {
                return null;
            }
        }
        #endregion
    }
}
